#include <iostream>
#include <stdio.h>
#include <cmath>

// 求数组最大值及下标
int max_of_array(int arr[],int n)
{
    int max = arr[0];
    int max_index = 0;
    for(int i = 1; i < n; i++)
    {
        if(arr[i] > max)
        {
            max = arr[i];
            max_index = i;
        }
    }
    return max_index;
}

int main()
{
    int arr[5] = {1, 2, 3, 4, 5};
    std::cout << "数组最大值为:" << arr[max_of_array(arr, 5)] << std::endl;
    std::cout << "数组最大值下标为:" << max_of_array(arr, 5) << std::endl;

    return 0;
}